<?php
class Contact extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this -> output -> enable_profiler(PROFILER);        //Instantiate a Doctrine Entity Manager        $this -> em = $this -> doctrine -> em;
    }    public function index() {		$data['pageTitle'] ="Contact Me";
 		$data['pageDescription'] = "Contact - If you want to share something or if you are interested in my services as a freelance, thank you :)";		         $data['main_content'] = "public/contact/index";
        $this -> load -> view("public/template", $data);
    }    public function send() {
        if ($this -> form_validation -> run('contact/send') == TRUE) {
            try {                $contact = new models\Contact();                models\Contact::prepareData($_POST, $contact);                $this -> em -> persist($contact);                $this -> em -> flush();                $this -> email -> from($contact -> getEmail(), $contact -> getName());                $list = array('ivan@branchcore.com', 'raul.ivan.82@hotmail.com', 'reversible_82@hotmail.com');                $this -> email -> to($list);                $this -> email -> subject('www.ethicalcoder.com | Contact Information');                $this -> email -> message($contact -> getMessage());                $this -> email -> send();                redirect('contact/thankyou');            } catch (Exception $e) {
                redirect('contact/sorry');
            }
        } else {
            $data['main_content'] = "public/contact/index";
            $this -> load -> view("public/template", $data);
        }
    }    public function thankyou() {        $data['main_content'] = "public/contact/thankyou";
        $this -> load -> view("public/template", $data);
    }    public function sorry() {
        $data['main_content'] = "public/contact/sorry";
        $this -> load -> view("public/template", $data);
    }}?>